package com.gelingqin.es.springbootdemo.controller;

import com.gelingqin.es.springbootdemo.service.ElasticsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author gelingqin
 * @Create 2021-12-18-15:44
 */
@RestController
@RequestMapping("/indexTemplate/")
public class IndexTemplateController {

    @Autowired
    private ElasticsearchService elasticsearchService;

    /**
     * 索引模板列表
     */
    @SuppressWarnings("rawtypes")
    @RequestMapping("listAll")
    public Map listAll() {
        return elasticsearchService.performRequest("GET","/_index_template",null,Map.class);
    }
    /**
     *
     * @param map
     * @return
     */
    @RequestMapping("create")
    public Map create(@RequestBody Map<String,Object> map){
        String id=(String)map.get("id");
        return elasticsearchService.performRequest("PUT","/_index_template/"+id,map.get("param"),Map.class);

    }



}
